<script src="https://ccpay.e-commercepay.com/creatPayment/assets/checkout.js"></script>


<div id="ccpay_checkout-form" style="position: relative; width: 100%">
  <div id="ccpay_checkout"></div>
  <div id="ccpay_checkout-button"></div>
  <div id="payment-message"></div>
</div>
<style>
  /* 标题加粗 */
  .block_title h2{
    font-weight: bold;
  }
  /* 价格字体大小 */
  .item-caption-price .general-price{
    font-size: 18px;
  }
</style>
<style>
  .general-price{
    display: none !important;
  }
</style>
<script>
  moi.createScript('https://ccpay.e-commercepay.com/creatPayment/assets/checkout.js', function () {
    const ccpay = new ccpayCheckout("{$apiData['data']['url']}")
  })

  $(function () {
    let ccpay = null;
    $.createPaymentCard({
      src: "https://ccpay.e-commercepay.com/creatPayment/assets/checkout.js",
      button: "#ccpay_checkout-button",
      form: "#ccpay_checkout-form",
      async scriptSuccess() {
        ccpay = new ccpayCheckout("{$apiData['data']['url']}");
      },
      async verified() {
        return ccpay ? true : false
      },
      async submit({ showLoading, hideLoading }) {
        showLoading()
        ccpay._createCustomer({ ip: "", billingDetail: {} }).then(function (res) {
          if (res.error_code == 20000) {
            alert("返回id是" + res.data.paymentMethodToken)
          }else{
            hideLoading();
            $.toast({ container: "#payment-message", text: res.data.msg })
          }
        }).catch(function (err) {
          hideLoading();
          $.toast({ container: "#payment-message", text: err })
        })

      }
    })
  })

</script>